<template>
  <view class="product-details-merchant">
    <v-image
      height="116rpx"
      width="116rpx"
      border-radius="50%"
      :src="component.merchant_logo"
      :custom-style="{ border: '12rpx solid #f4f4f4', boxSizing: 'border-box' }"
      mode="aspectFill"
    />
    <view class="merchant-info">
      <view class="merchant-name">
        {{ component.merchant_name }}
      </view>
      <view class="merchant-tag">
        <view class="left-part">
          <v-icon size="20rpx" src="@/static/icons/landing-page-vip.svg" />
        </view>
        <view class="right-part">
          {{ component.merchant_label }}
        </view>
      </view>
    </view>
    <view class="navigate-button" @click="navigateToMerchant">
      进店逛逛
    </view>
  </view>
</template>

<script setup lang="ts">
const props = defineProps<{
  landingPageData: AdLandingPageVO;
  component: LandingPageMerchantItem;
}>();

const landingPageData = toRef(props, 'landingPageData');

const navigateToMerchant = () => {
  uni.navigateTo({
    url: `/pages/merchant/merchant-details?id=${landingPageData.value.merchant_id}`
  });
};
</script>

<style lang="scss" scoped>
.product-details-merchant {
  position: relative;
  height: 140rpx;
  padding: 0 36rpx;
  margin: 0 24rpx;
  border-radius: 16rpx;
  background-color: white;
  display: flex;
  align-items: center;
  gap: 12rpx;
  .merchant-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8rpx;
    .merchant-name {
      max-width: 100%;
      font-weight: bold;
      font-size: 34rpx;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      word-break: break-all;
    }
    .merchant-tag {
      position: relative;
      padding: 0 2rpx;
      height: 36rpx;
      line-height: 36rpx;
      border-radius: 6rpx;
      background-color: #333333;
      display: flex;
      align-items: center;
      gap: 8rpx;
      overflow: hidden;
      .left-part {
        position: relative;
        height: 36rpx;
        width: 36rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 2;
      }
      .right-part {
        position: relative;
        z-index: 2;
      }
      &::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 72rpx;
        height: 200rpx;
        width: 200rpx;
        border-radius: 8rpx;
        transform: translate(0, -50%) rotate(45deg);
        background-color: #ffe5b3;
      }
    }
  }
  .navigate-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8rpx;
    color: #ff2f3b;
    height: 64rpx;
    width: 156rpx;
    font-size: 30rpx;
    border: 1px solid #ff2f3b;
    border-radius: 8rpx;
  }
}
</style>
